package gang.org.springframework.boot.autoconfigure.web.servlet.server;


import gang.org.springframework.boot.web.server.GangAbstractConfigurableWebServerFactory;
import gang.org.springframework.boot.web.servlet.GangServletContextInitializer;
import gang.org.springframework.boot.web.servlet.server.GangDocumentRoot;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @Author：gang.chen
 * @Date：2023/8/8 13:25
 */
public abstract class GangAbstractServletWebServerFactory extends GangAbstractConfigurableWebServerFactory implements GangConfigurableServletWebServerFactory{

    public String displayName = "application";

    public String contextPath = "";

    public boolean registerDefaultServlet = false;

    public final GangDocumentRoot documentRoot = new GangDocumentRoot(null);

    public final File getValidDocumentRoot(){
        return this.documentRoot.getValidDirectory();
    }

    public final GangServletContextInitializer[] mergeInitializers(GangServletContextInitializer... initializers){

        List<GangServletContextInitializer> mergedInitializers = new ArrayList<>();
        //TODO
        mergedInitializers.addAll(Arrays.asList(initializers));

        return mergedInitializers.toArray(new GangServletContextInitializer[0]);
    }

    public String getContextPath() {
        return contextPath;
    }

    public String getDisplayName() {
        return displayName;
    }

    public void setDisplayName(String displayName) {
        this.displayName = displayName;
    }

    public boolean isRegisterDefaultServlet() {
        return registerDefaultServlet;
    }
}
